/*-------------------------------------------------------------------------
 * CLR版本:     4.0.30319.42000
 * 创建人:      song
 * 创建时间：   2024/4/9 17:56:20
 * 功 能：      绘制器基类
 *-------------------------------------------------------------------------*/

#if UNITY_EDITOR
namespace SCore.Editor.SShaderDraw
{
    using System.Collections.Generic;
    using UnityEditor;
    using UnityEngine;

    public abstract class SPropBase
    {
        protected GUIContent lable;
        protected Material material;
        public string name;
        protected Dictionary<string, MaterialProperty> props;
        protected Color resBtnColor = new Color(0.9f, 1f, 1f);
        public static Color ResetBtnColor = new Color(0.9f, 1f, 1f);
        protected GUIStyle guiStyle;
        public static GUIStyle fontStyle = SShaderEditorHelpr.GetInternelStyle("ShurikenToggleMixed");
        protected MaterialEditor materialEditor;

        public SPropBase(string name, GUIContent lable, MaterialEditor materialEditor,
            Dictionary<string, MaterialProperty> props, GUIStyle guiStyle = null)
        {
            this.name = name;
            this.materialEditor = materialEditor;
            this.material = materialEditor.target as Material;
            this.lable = lable;
            this.props = props;
            this.guiStyle = guiStyle;
        }

        public abstract void Draw(float space, float BtnSize = 40);

        public void Reset()
        {
            if (this.props.ContainsKey(name))
            {
                if (this is STextureProp)
                    return;
                this.ResetDefaultValue();
            }
        }

        protected abstract void ResetDefaultValue();

        public bool Exist
        {
            get
            {
                bool flag = this.material.HasProperty(this.name);
                return this.props.ContainsKey(this.name) & flag;
            }
        }
    }
}
#endif